#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int a[1000006];
int main(){
	int n,flag=0,l=0,r=0;
	cin>>n;
	a[0]=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(flag==0&&a[i]<a[i-1]) {
			flag=1;
			l=i-1;
		}
		else if(flag==1) {
			if(a[i]>a[i-1]) {
				r=i-1;
				flag=2;
			}
		}
		else if(flag==2) {
			if(a[i]<a[i-1]) flag=3;
		}
		
	}
		for(int i=l-1;i>=1;i--){
			if(a[i]==a[l]) l=i;
			else if(a[i]!=a[l]) break;
		}
		a[n+1]=1000000006;
		if(flag==1) r=n;
		if(flag==3) cout<<"impossible"<<endl;
		else if(flag==0) cout<<"1"<<" "<<"1"<<endl;
		else if(a[r]>=a[l-1]&&a[l]<=a[r+1]) cout<<l<<" "<<r<<endl;
		else cout<<"impossible"<<endl;
	return 0;
}